<!--
 * @description  : 案件-附件上传
 * @descriptionDetail: 案件-附件上传
 * @copyright    : 浙江烟草
 * @author       : sy
 * @create       : 2022-08-25 15:43:11
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar
      :is-white="false"
      :title="navTitle"
      :custom-back="goBack"
      style="z-index: 99999"
    >
    </theme-navbar>
    <!-- #endif -->
    <!-- c_doc_file_attr -->
    <view class="content">
      <m-offical-upload
        :deletable="isDisabled"
        :disabled="!isDisabled"
        width="150rpx"
        height="150rpx"
        :file-list="officialPicList"
        :multiple="false"
        index="officialPicList"
        :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.c_doc_file_attr,'bizId':params['liddId']}"
        upApiUrl="uploadBase64File"
        ref="officialPicUpload"
        @on-list-change="changeUpload"
      >
      </m-offical-upload>
    </view>
  </view>
</template>

<script>
import commonService from '@/service/common/common.service';
import officeService from '@/service/case/office.service.js';
import MOfficalUpload from '../components/mOfficalUpload.vue';
import {
  PATHROOT,
} from '@/common/path.config.js';
export default{
  components:{
    MOfficalUpload,
  },
  data(){
    return {
      isDisabled:false,
      officialPicList:[],
      params:{},
    }
  },
  mounted () {
    this.params = this.getRouteParam();
    this.isDisabled = this.params.isPicUploadable;
    this.userInfo = uni.getStorageSync("user");
    this.initData();
  },
  methods:{
    initData(){
      this.$modal.showLoading("正在查询附件...");
      let self = this;
      officeService.officeAttachment({bizId: this.params['liddId'],}).then(res => {
        self.$modal.hideLoading();
        console.log("文件关联附件", res);
        this.officialPicList = [...res.data,];
      }).catch(err => {
        self.$modal.hideLoading();
        self.$u.toast(err);
      });
    },

    // 上传/删除图片事件
    changeUpload(list, key){
      if(list.length > 0){
        this.officialPicList = [...list,];
      }else{
        this.officialPicList = [];
      }
    },
  },
}
</script>

<style>
</style>
